package map.android.baidu.carpool.data.impl;

import android.content.Context;

import com.baidu.platform.comapi.basestruct.GeoPoint;

import map.android.baidu.carpool.WebConfig;
import map.android.baidu.carpool.data.CarpoolBaseData;
import map.android.baidu.carpool.model.CarpoolPosition;
import map.android.baidu.carpool.response.AccountResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zhangtongyu on 15/3/25.
 * main模块计费接口request
 */
public class AccountData extends CarpoolBaseData<AccountResponse> {

    private String v; //版本号
    private GeoPoint startGeo; // 出发地坐标
    private GeoPoint endGeo; //目的地坐标
    private String time = "";

    public AccountData(Context context) {
        super(context);
    }

    public void setEndGeo(GeoPoint endGeo) {
        this.endGeo = endGeo;
    }

    public void setStartGeo(GeoPoint startGeo) {
        this.startGeo = startGeo;
    }

    public void setV(String v) {
        this.v = v;
    }

    public void setTime(String time) {
        this.time = time;
    }

    @Override
    protected String getUrl() {
        return WebConfig.getUrl(WebConfig.URL_ID_ACCOUNT);
    }

    @Override
    protected Map<String, String> getParams() {

        Map<String, String> params = new HashMap<String, String>();
        // params.put("v" , v);
        params.put("s_x", getGeoYString(startGeo));
        params.put("s_y", getGeoXString(startGeo));
        params.put("e_x", getGeoYString(endGeo));
        params.put("e_y", getGeoXString(endGeo));
        params.put("time",time);
        return params;
    }

    private String getGeoXString(GeoPoint geoPoint) {
        String geoX = "";
        if (geoPoint != null) {
            geoX = String.valueOf(geoPoint.getLongitude());
        }

        return geoX;
    }

    private String getGeoYString(GeoPoint geoPoint) {

        String geoY = "";
        if (geoPoint != null) {
            geoY = String.valueOf(geoPoint.getLatitude());
        }

        return geoY;

    }
}
